/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package kimo.bl;

import java.util.List;
import kimo.persistence.entities.Producer;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.select.SelectorComposer;
import org.zkoss.zk.ui.select.annotation.Listen;
import org.zkoss.zk.ui.select.annotation.Wire;
import org.zkoss.zul.ListModelList;
import org.zkoss.zul.Listbox;

/**
 *
 * @author a381u296
 */
public class Pending extends SelectorComposer<Component> {

    
    @Wire
    private Listbox pendingLst;
    
    private ListModelList<Producer> pendingLstLml;

    @Override
    public void doAfterCompose(Component comp) throws Exception {
        super.doAfterCompose(comp); //To change body of generated methods, choose Tools | Templates.
        
        KimoDAO pdao = new KimoDAO();
        List<Producer> producers = pdao.findPending();
        pendingLstLml = new ListModelList<Producer>(producers);
        pendingLst.setModel(pendingLstLml);
        
    }
    

    
    

    @Listen("onSelect = #pendingLst")
    public void onSelect() {
        Producer producer = pendingLstLml.getSelection().iterator().next();
        Executions.sendRedirect("?pid="+producer.getProducerId());
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
}
